/**
 *  Copyright 2011 Marco Berri - marcoberri@gmail.com
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations under the License.
 **/
package com.mbfasttrack.model;

import java.util.ArrayList;
import java.util.List;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

/**
 * @author Marco Berri marcoberri@gmail.com http://tecnicume.blogspot.com
 */
@Document
public class Hardware implements Base {

    @Id
    @Indexed
    private String id;
    private String producer;
    private String model;
    private String slug;
    private String software;
    private String description;
    private String url;
    @Transient
    private CommonsMultipartFile image;
    @DBRef
    private List<Media> media = new ArrayList();
    @DBRef
    private User user;

    /**
     * 
     * @return
     */
    public String toString() {
        return "[ id: " + this.getId()
                + " model:" + this.getModel()
                + " producer:" + this.getProducer()
                + " description:" + this.getDescription()
                + " software:" + this.getSoftware()
                + " url:" + this.getUrl()
                + " slug:" + this.getSlug()
                + " image:" + this.image
                + " media:" + this.media
                + " ]";
    }

    /**
     * 
     */
    public Hardware() {
    }

    /**
     * @return the id
     */
    public String getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(String id) {
        this.id = id;
    }

    public String getModel() {
        return model;
    }

    /**
     * @param name 
     */
    public void setModel(String model) {
        this.model = model;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the slug
     */
    public String getSlug() {
        return slug;
    }

    /**
     * @param slug the slug to set
     */
    public void setSlug(String slug) {
        this.slug = slug;
    }

    /**
     * @return the url
     */
    public String getUrl() {
        return url;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * @return the image
     */
    public CommonsMultipartFile getImage() {
        return image;
    }

    /**
     * @param image the image to set
     */
    public void setImage(CommonsMultipartFile image) {
        this.image = image;
    }

    /**
     * @return the media
     */
    public List<Media> getMedia() {
        return media;
    }

    /**
     * @param media the media to set
     */
    public void setMedia(List<Media> media) {
        this.media = media;
    }

    /**
     * 
     * @param media
     */
    public void addMedia(Media media) {

        if (this.media == null) {
            this.media = new ArrayList<Media>();
        }

        this.media.add(media);
    }

    /**
     * @return the user
     */
    public User getUser() {
        return user;
    }

    /**
     * @param user the user to set
     */
    public void setUser(User user) {
        this.user = user;
    }

    /**
     * @return the producer
     */
    public String getProducer() {
        return producer;
    }

    /**
     * @param producer the producer to set
     */
    public void setProducer(String producer) {
        this.producer = producer;
    }

    /**
     * @return the software
     */
    public String getSoftware() {
        return software;
    }

    /**
     * @param software the software to set
     */
    public void setSoftware(String software) {
        this.software = software;
    }
}
